package com.ruoyi.web.controller.mall.mallShopType.controller;

import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.web.controller.mall.mallShopType.domain.MallShopType;
import com.ruoyi.web.controller.mall.mallShopType.service.IMallShopTypeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 商家注册行业类别Controller
 * 
 * @author ruoyi
 * @date 2021-01-18
 */
@Controller
@RequestMapping("/mall/mallShopType")
public class MallShopTypeController extends BaseController
{
    private String prefix = "mall/mallShopType";

    @Autowired
    private IMallShopTypeService mallShopTypeService;

//    @RequiresPermissions("mall:mallShopType:view")
    @GetMapping()
    public String mallShopType()
    {
        return prefix + "/mallShopType";
    }

    /**
     * 查询商家注册行业类别列表
     */
//    @RequiresPermissions("mall:mallShopType:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(MallShopType mallShopType)
    {
        startPage();
        List<MallShopType> list = mallShopTypeService.selectMallShopTypeList(mallShopType);
        return getDataTable(list);
    }

    /**
     * 导出商家注册行业类别列表
     */
//    @RequiresPermissions("mall:mallShopType:export")
    @Log(title = "商家注册行业类别", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(MallShopType mallShopType)
    {
        List<MallShopType> list = mallShopTypeService.selectMallShopTypeList(mallShopType);
        ExcelUtil<MallShopType> util = new ExcelUtil<MallShopType>(MallShopType.class);
        return util.exportExcel(list, "mallShopType");
    }

    /**
     * 新增商家注册行业类别
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存商家注册行业类别
     */
//    @RequiresPermissions("mall:mallShopType:add")
    @Log(title = "商家注册行业类别", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(MallShopType mallShopType)
    {
        return toAjax(mallShopTypeService.insertMallShopType(mallShopType));
    }

    /**
     * 修改商家注册行业类别
     */
    @GetMapping("/edit/{id}")
    public String edit(@PathVariable("id") String id, ModelMap mmap)
    {
        MallShopType mallShopType = mallShopTypeService.selectMallShopTypeById(id);
        mmap.put("mallShopType", mallShopType);
        return prefix + "/edit";
    }

    /**
     * 修改保存商家注册行业类别
     */
//    @RequiresPermissions("mall:mallShopType:edit")
    @Log(title = "商家注册行业类别", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(MallShopType mallShopType)
    {
        return toAjax(mallShopTypeService.updateMallShopType(mallShopType));
    }

    /**
     * 删除商家注册行业类别
     */
//    @RequiresPermissions("mall:mallShopType:remove")
    @Log(title = "商家注册行业类别", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String[] ids)
    {
        return toAjax(mallShopTypeService.deleteMallShopTypeByIds(ids));
    }
}
